package com.flyduck.vueshop.cart.remote.controller;

import com.flyduck.vueshop.cart.remote.service.RemoteCartItemService;
import com.flyduck.vueshop.cart.vo.RemoteCartItemRespVO;
import com.flyduck.vueshop.common.core.lang.Result;
import com.flyduck.vueshop.common.sotoken.annotation.InnerAuth;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * RemoteCartItemController
 * </p>
 *
 * @author flyduck
 * @since 2024-07-23
 */
@RestController
@RequestMapping("/cart/remote/cartItem")
public class RemoteCartItemController {

    @Resource
    private RemoteCartItemService remoteCartItemService;

    @InnerAuth
    @PostMapping("/getCartItemListByIds")
    Result<List<RemoteCartItemRespVO>> getCartItemListByIds(@RequestBody List<Long> ids){
        List<RemoteCartItemRespVO> remoteCartItemRespVOList = remoteCartItemService.getCartItemListByIds(ids);
        return Result.success(remoteCartItemRespVOList);
    }

    @InnerAuth
    @PostMapping("/deleteByIds")
    Result<Void> deleteByIds(@RequestBody List<Long> ids){
        remoteCartItemService.deleteByIds(ids);
        return Result.success();
    }
}
